package biolabs.visual

import biolabs.gui.WindowSink

import VisualizationConfiguration._

/** Represents a visualization method (technology), such as Java2D, Java3D, ...
  *
  * @param R type of visual representation that this visualization method
  * is able to consume (e.g. display or write to a file).
  */
abstract class VisualizationMethod[R](val name: String)(implicit val producedType: Manifest[R]) {

	/** An entry point for configuring visualization using internal
	 * DSL described at [[biolabs.visual.VisualizationConfiguration]].
	 */
	final def configure(items: Item[_, R]*): VisualizationConfiguration[R] =
		new VisualizationConfiguration(this, items.toList)

	/** Indicates whether this visualization method supports on-screen
	  * visualization in a GUI window.
	  */
	def supportsOnScreen(): Boolean

	/** Creates a window that serves as a sink that consumes (and displays)
	  * visual representations. If this method does not support on-screen
	  * visualization, returns `None`.
	  */
	def createWindow(): Option[WindowSink[R]]

	/** Creates an empty visualization configuration. */
	final def emptyConfiguration() =
		new VisualizationConfiguration[R](this, Nil)

	/** Combines multiple visual representations into one.
	  * @param representations collection of visual representations
	  * to combine. Must not be empty.
	  */
	def combine(representations: Iterable[R]): R

	/** Returns this method's name. */
	override def toString() = name
}
